<template>
    <div class="numberBox">
        <div class="mui-numbox" data-numbox-min='1'>
            <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
            <input class="mui-input-numbox" type="number" ref="num" @change="getNum">
            <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
        </div>
    </div>
</template>

<script>
    import mui from '../../lib/mui/dist/js/mui.min.js';
    export default {
        mounted() {
            mui('.mui-numbox').numbox();
        },
        methods: {
            getNum() {
                this.$emit('getnumber',this.$refs.num.value);
            },
        },
        props: ['max'],
        watch: {
            max : (newNumber,oldNumber) => {
                mui('.mui-numbox').numbox().setOption('max',newNumber)
            } 
        }
    }
</script>

<style lang="less">
    .numberBox {
        display: inline-block;
    }
</style>